package com.landinfo.service.impl;

import com.landinfo.service.VrManageService;
import com.landinfo.domain.VrManage;
import com.landinfo.repository.VrManageRepository;
import com.landinfo.service.dto.VrManageDTO;
import com.landinfo.service.mapper.VrManageMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Service Implementation for managing VrManage.
 */
@Service
@Transactional
public class VrManageServiceImpl implements VrManageService{

    private final Logger log = LoggerFactory.getLogger(VrManageServiceImpl.class);

    private final VrManageRepository vrManageRepository;

    private final VrManageMapper vrManageMapper;

    public VrManageServiceImpl(VrManageRepository vrManageRepository, VrManageMapper vrManageMapper) {
        this.vrManageRepository = vrManageRepository;
        this.vrManageMapper = vrManageMapper;
    }

    /**
     * Save a vrManage.
     *
     * @param vrManageDTO the entity to save
     * @return the persisted entity
     */
    @Override
    public VrManageDTO save(VrManageDTO vrManageDTO) {
        log.debug("Request to save VrManage : {}", vrManageDTO);
        VrManage vrManage = vrManageMapper.toEntity(vrManageDTO);
        vrManage = vrManageRepository.save(vrManage);
        return vrManageMapper.toDto(vrManage);
    }

    /**
     *  Get all the vrManages.
     *
     *  @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public List<VrManageDTO> findAll() {
        log.debug("Request to get all VrManages");
        return vrManageRepository.findAll().stream()
            .map(vrManageMapper::toDto)
            .collect(Collectors.toCollection(LinkedList::new));
    }

    /**
     *  Get one vrManage by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public VrManageDTO findOne(Long id) {
        log.debug("Request to get VrManage : {}", id);
        VrManage vrManage = vrManageRepository.findOneById(id);
        return vrManageMapper.toDto(vrManage);
    }

    /**
     *  Delete the  vrManage by id.
     *
     *  @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete VrManage : {}", id);
        vrManageRepository.deleteById(id);
    }
}
